#include "cmd_err_code.hpp"
#include "balance_cmd.hpp"

namespace cmd
{
	void SSReportLoadReq::serialize(Streamer & streamer)
	{
		SSHead::serialize(streamer);
		streamer & _ip
			     & _port
				 & _load;
	};

	const std::string SSReportLoadReq::to_string() const
	{
		std::ostringstream oss;
		oss << SSHead::to_string()
			<< " body: {ip: " << _ip
			<< ", port: " << _port
			<< ", load: " << _load
			<< "}";
		return oss.str();
	}

	void SCGetMinLoadRes::serialize(Streamer & streamer)
	{
		SCHead::serialize(streamer);
		streamer & _err_code;
		if (0 != _err_code)
		{
			return;
		}

		streamer & _ip
			     & _port;
	}

	const std::string SCGetMinLoadRes::to_string() const
	{
		std::ostringstream oss;

		oss << SCHead::to_string()
			<< " body: {err_code: " << (int)_err_code << "(" << game_err_to_str(_err_code) << ")";
			
		if (0 != _err_code)
		{
			oss << "}";
			return oss.str();
		}

		oss << ", ip: " << _ip
			<< ", port: " << _port
			<< "}";
		return oss.str();
	}
};

